package main

import (
	maker2 "api/libs/maker"
	"gitee.com/dreamwood/ez-maker/maker"
)

func main() {
	maker2.Prepare()
	Target()
	TargetUser()
	TargetRole()
	TargetJob()
	TargetDept()
	TargetGroup()
}

func Target() {
	c := maker.CreateTable("Target", "目标群体", "oa")
	c.AddName()
	c.AddBool("isAll", "是否群发")
	c.AddOneToMany("depts", "部门", "TargetDept").SetNullable(true)
	c.AddOneToMany("jobs", "岗位", "TargetJob").SetNullable(true)
	c.AddOneToMany("roles", "角色", "TargetRole").SetNullable(true)
	c.AddOneToMany("users", "用户", "TargetUser").SetNullable(true)
	c.AddManyToMany("groups", "分组", "TargetGroup").SetIsControl(false)
	c.Generate()
}

func TargetDept() {
	c := maker.CreateTable("TargetDept", "目标部门", "oa")
	c.AddInt("srcId", "源ID")
	c.AddName()
	c.AddManyToOne("target", "所属", "Target")
	c.Generate()
}

func TargetJob() {
	c := maker.CreateTable("TargetJob", "目标岗位", "oa")
	c.AddInt("srcId", "源ID")
	c.AddName()
	c.AddManyToOne("target", "所属", "Target")
	c.Generate()
}

func TargetRole() {
	//角色不应该出现在筛选中，冗余设计，暂时不用
	c := maker.CreateTable("TargetRole", "目标角色", "oa")
	c.AddInt("srcId", "源ID")
	c.AddName()
	c.AddManyToOne("target", "所属", "Target")
	c.Generate()
}

func TargetUser() {
	c := maker.CreateTable("TargetUser", "目标用户", "oa")
	c.AddInt("srcId", "源ID")
	c.AddName()
	c.AddManyToOne("target", "所属", "Target")
	c.Generate()
}

func TargetGroup() {
	c := maker.CreateTable("TargetGroup", "目标分组", "oa")
	c.AddName()
	c.AddManyToMany("targets", "目标用户", "Target").SetIsControl(true)
	c.AddInt("weight", "权重")
	c.Generate()
}
